package com.yjt.fresh.adpater;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yjt.fresh.R;
import com.yjt.fresh.bean.BeanGoodsCategories;
import com.yjt.fresh.bean.BeanHomePage;

import java.util.List;

/**
 * 首页分类适配器
 *
 * @author mcc
 * @date 2018/6/10
 */

public class AdpRvMainAtyHomePageCategory extends BaseQuickAdapter<BeanGoodsCategories, BaseViewHolder> {


    public AdpRvMainAtyHomePageCategory(int layoutResId, @Nullable List<BeanGoodsCategories> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanGoodsCategories item) {
        int position = helper.getAdapterPosition();
        TextView tv = helper.getView(R.id.tv_app_recycle_item_homepage_category);
        ImageView iv  = helper.getView(R.id.iv_app_recycle_item_homepage_category);
        if (mData != null && mData.size() > 0) {
            if (mData.size() > 9 && position == mData.size()-1 ){
                tv.setText("更多");
                iv.setImageResource(R.mipmap.b_ic_05);
            }else {
                tv.setText(item.getTITLE());
                Glide.with(mContext).load(item.getCOVER_IMG()).placeholder(R.mipmap.image_default).into(iv);
            }
        }
    }
}
